<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>08-Vue生命周期</title>
    <script src="../js/vue.js"></script>
</head>
<body>
<!--1. 准备一个容器-->
<div id="app">
    <div id="box">{{age}}</div>
    <button @click="fun1()">修改age的值</button>
    <button @click="fun2()">销毁Vue</button>
</div>
<script>
    let vm = new Vue({
        el: "#app",
        data: {
            age:18,
        },
        methods:{
            fun1:function () {
                this.age++;
            },
            fun2:function () {
                // 销毁Vue对象
                this.$destroy();
            }
        },
        beforeCreate:function () {
            console.log("创建对象后,data数据没初始化之前" + this.age);
        },
        created:function () {
            console.log("创建对象后,data数据初始化之后执行"+ this.age);
        },
        beforeMount:function () {
            console.log("渲染之前"+this.age);
        },
        mounted:function () {
            console.log("渲染之后"+this.age);
        },
        beforeUpdate:function () {
            console.log("修改前"+this.age);
        },
        updated:function () {
            console.log("修改之后" + this.age);
        },
        beforeDestroy:function () {
            console.log("销毁前")
        },
        destroyed:function(){
            console.log("销毁后")
        }
    });
</script>


</body>
</html>